package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import java.util.Locale;

import org.antlr.v4.runtime.misc.NotNull;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.SelectStatementContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.StreamNameContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.StreamSourceContext;

public class StreamSourceVisitor extends AbsCQLParserBaseVisitor<StreamSourceContext>{

	private StreamSourceContext context = null;
	
	public StreamSourceVisitor() {
		context = new StreamSourceContext();
	}
	
	@Override
	protected StreamSourceContext defaultResult() {
		return context;
	}
	
	@Override
	public StreamSourceContext visitStreamName(@NotNull StreamNameContext ctx) {
		context.setStreamName(ctx.getText().toLowerCase(Locale.US));
        return context;
	}
	
	@Override
	public StreamSourceContext visitSelectStatement(@NotNull SelectStatementContext ctx) {
		SelectStatementVisitor visitor = new SelectStatementVisitor();
        context.setSubQuery(visitor.visit(ctx));
        return context;
	}
}
